<?php
namespace api\service;

use api\service\interfaces\IMpeService;
use common\service\interfaces\IModel;
use herosphp\bean\Beans;
use herosphp\core\Loader;
use herosphp\utils\AjaxResult;

Loader::import('api.service.interfaces.IMpeService');

/**
 * 牌号 api(Service)接口实现
 * @author yuliang
 */
class MpeService implements IMpeService
{


    /**
     * @see \api\service\interfaces\IMpeService::getItem
     */
    public function getItem($mpeid)
    {
        $service = Beans::get('app.mpe.service');
        $item = $service->getItem($mpeid);
        if ( $item == false ) {
            return AjaxResult::fail("找不到符合条件的记录.");
        } else {
            $vo = AjaxResult::success("获取数据成功.");
            $vo->putItem($item);
            return $vo;
        }
    }

    /**
     * MPE会员对应的APPID获取大塑支付的用户信息
     * @param $appid
     * @param $fields string 需要获取的字段
     * @return AjaxResult
     */
    public function getUserByAppId( $appid, $fields="userid" ){
        $condition['id'] = $appid;
        $service = Beans::get('app.mpe.service');
        $item = $service -> getItem($condition,$fields,null);
        if( $item ){
            return new AjaxResult(AjaxResult::OP_SUCCESS,"success",$item);
        }else{
            return new AjaxResult(AjaxResult::OP_FAILURE,"appid not found",null);
        }
    }
}
